/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "prodgroup", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"groupId"})})
@NamedQueries({@NamedQuery(name = "Prodgroup.findAll", query = "SELECT p FROM Prodgroup p"), @NamedQuery(name = "Prodgroup.findByGroupId", query = "SELECT p FROM Prodgroup p WHERE p.groupId = :groupId"), @NamedQuery(name = "Prodgroup.findByGroupDescription", query = "SELECT p FROM Prodgroup p WHERE p.groupDescription = :groupDescription"), @NamedQuery(name = "Prodgroup.findByGroupName", query = "SELECT p FROM Prodgroup p WHERE p.groupName = :groupName"), @NamedQuery(name = "Prodgroup.findByIsActive", query = "SELECT p FROM Prodgroup p WHERE p.isActive = :isActive")})
public class Prodgroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "groupId", nullable = false)
    private Integer groupId;
    @Basic(optional = false)
    @Column(name = "groupDescription", nullable = false, length = 150)
    private String groupDescription;
    @Basic(optional = false)
    @Column(name = "groupName", nullable = false, length = 50)
    private String groupName;
    @Column(name = "isActive", length = 10)
    private String isActive;
    @JoinColumn(name = "DId", referencedColumnName = "DId")
    @ManyToOne
    private Department dId;
    @OneToMany(mappedBy = "groupId")
    private Collection<Product> productCollection;

    public Prodgroup() {
    }

    public Prodgroup(Integer groupId) {
        this.groupId = groupId;
    }

    public Prodgroup(Integer groupId, String groupDescription, String groupName) {
        this.groupId = groupId;
        this.groupDescription = groupDescription;
        this.groupName = groupName;
    }

    public Integer getGroupId() {
        return groupId;
    }

    public void setGroupId(Integer groupId) {
        this.groupId = groupId;
    }

    public String getGroupDescription() {
        return groupDescription;
    }

    public void setGroupDescription(String groupDescription) {
        this.groupDescription = groupDescription;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getIsActive() {
        return isActive;
    }

    public void setIsActive(String isActive) {
        this.isActive = isActive;
    }

    public Department getDId() {
        return dId;
    }

    public void setDId(Department dId) {
        this.dId = dId;
    }

    public Collection<Product> getProductCollection() {
        return productCollection;
    }

    public void setProductCollection(Collection<Product> productCollection) {
        this.productCollection = productCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (groupId != null ? groupId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prodgroup)) {
            return false;
        }
        Prodgroup other = (Prodgroup) object;
        if ((this.groupId == null && other.groupId != null) || (this.groupId != null && !this.groupId.equals(other.groupId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Prodgroup[groupId=" + groupId + "]";
    }

}
